<?php
if (isset($user) and ($user)) {
    ?>
    <script type="text/javascript">

        //Initialize 2nd demo:
        ddaccordion.init({
            headerclass: "technology", //Shared CSS class name of headers group
            contentclass: "thelanguage", //Shared CSS class name of contents group
            revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover"
            mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover
            collapseprev: false, //Collapse previous content (so only one open at any time)? true/false 
            defaultexpanded: [], //index of content(s) open by default [index1, index2, etc]. [] denotes no content.
            onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed)
            animatedefault: false, //Should contents open by default be animated into view?
            persiststate: false, //persist state of opened contents within browser session?
            toggleclass: ["closedlanguage", "openlanguage"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
            togglehtml: ["prefix", " ", " "], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
            animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow"
            oninit:function(expandedindices){ //custom code to run when headers have initalized
                //do nothing
            },
            onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed
                //do nothing
            }
        })

    </script>

    <div class="cat_page">
        <h5>
            <?php
            echo $user['User']['name'];
            ?>
        </h5>
        <div class="cat_page_left ">
            <div class="seller_right_pro">
                <div class="seller_pro_img">
                    <?php
                    if (isset($user['User']['img']) and ($user['User']['img'])) {
                        echo $html->image('User/' . $user['User']['img'], array(
                            'width' => '371',
                            'height' => '240'
                        ));
                    }
                    ?>
                </div>
            </div>
            <div class="def_div f_left"> 
    <?php
    echo $html->link('Edit Profile Image', array(
        'controller' => 'users',
        'action' => 'account_setting',
            ), array(
        'class' => 'brown_link'
    ));
    ?><br/>
                <?php
                echo $html->link('Edit Profile', array(
                    'controller' => 'users',
                    'action' => 'account_setting',
                        ), array(
                    'class' => 'blk_link'
                ));
                ?><br/>
                <?php
                echo $html->link('Create a Wishlist', array(
                    'controller' => 'products',
                    'action' => 'add_to_wishlist',
                    'func' => 'create'
                        ), array(
                    'class' => 'blk_link'
                ));
                ?>
            </div>
        </div>
        <div class="cat_page_right ">
            <h2> Wishlist</h2>
    <?php
    if (isset($user_wish_listes) and ($user_wish_listes)) {
        ?>
                <?php
                $x_w = 1;
                foreach ($user_wish_listes as $user_wish_list) {
                    if (isset($x_w) and ($x_w == 1)) {
                        $tec = "";
                        $the_lang = "";
                    } else {
                        $tec = "technology";
                        $the_lang = "thelanguage";
                    }
                    ?>
                    <div class="item_list_show">
                        <div class="def_div f_left "><span class="font_16 blue <?php
            echo $tec;
                    ?>">
                    <?php
                    echo $x_w;
                    ?>
                                .<b>
                            <?php
                            echo $user_wish_list['Wishlist']['name'];
                            ?>
                                </b></span> <span class="manage_W_list"> <a class="org_link f_right">Manage This List</a>
                                <ul class="manage_W_list_S">
                                    <li>
                                    <?php
                                    echo $html->link('Edit This List', array(
                                        'controller' => 'products',
                                        'action' => 'add_to_wishlist',
                                        'func' => 'editwishlist',
                                        'hash' => $user_wish_list['Wishlist']['hash']
                                            ), array(
                                        'escape' => false
                                    ));
                                    ?>
                                    </li>
                                    <li>
                                        <?php
                                        echo $html->link('Delete this Wishlist', array(
                                            'controller' => 'products',
                                            'action' => 'delete',
                                            'Wishlist',
                                            base64_encode($user_wish_list['Wishlist']['id']),
                                            'MyWishlist'
                                                ), array(
                                            'escape' => false,
                                            'class' => ''
                                                ), 'Are you sure?');
                                        ?>
                                    </li>
                                </ul>
                            </span> </div>
                        <div class="pad_10"></div>
                        <div class="common_border1"></div>
                        <div class="def_div f_left <?php
                            echo $the_lang;
                            ?>">
            <?php
            if (isset($user_wish_list['Wishlist']['Products']) and ($user_wish_list['Wishlist']['Products'])) {
                ?>
                                <ul class="ul_prod_listing">
                            <?php
                            $x = 1;
                            $prs = $user_wish_list['Wishlist']['Products'];
                            foreach ($prs as $product) {
                                ?>
                                        <li>
                                            <div class="width_20 f_left">
                                        <?php
                                        echo $html->link($html->image('Product/' . $product['WishlistProduct']['Product']['img'], array(
                                                    'width' => '100',
                                                    'height' => 'auto'
                                                )), array(
                                            'controller' => 'products',
                                            'action' => 'product',
                                            $product['WishlistProduct']['Product']['slug']
                                                ), array(
                                            'escape' => false
                                        ));
                                        ?>
                                            </div>
                                            <div class="width_60 f_left">
                                                <div class="item_list_B">
                                                    <ul>
                                                        <li><span>
                                                <?php
                                                echo $html->link($product['WishlistProduct']['Product']['name'], array(
                                                    'controller' => 'products',
                                                    'action' => 'product',
                                                    $product['WishlistProduct']['Product']['slug']
                                                        ), array(
                                                    'escape' => false,
                                                    'class' => ''
                                                ));
                                                ?>
                                                            </span></li>
                                                        <li>
                                                            <p>By
                                                                <?php
                                                                echo $product['WishlistProduct']['Product']['Brand']['name'];
                                                                ?>
                                                            </p>
                                                        </li>
                                                        <li>
                                                            <div class="rating_<?php
                                            echo $product['WishlistProduct']['Product']['rating'];
                                            ?> f_left">&nbsp;</div>
                                                            <p>&nbsp;
                                                                <?php
                                                                __get_pr_reviews($product['WishlistProduct']['Product']['id']);
                                                                ?>
                                                            </p>
                                                        </li>
                                                        <li>
                                                            <p> <span class="over_line"><b>$
                                                                 <?php
                                                                 echo $product['WishlistProduct']['Product']['msrp'];
                                                                 ?>
                                                                    </b></span> <span class="red"><b>$
                                                                <?php
                                                                echo $product['WishlistProduct']['Product']['MasterProduct']['price'];
                                                                ?>
                                                                    </b></span> </p>
                                                        </li>
                                                        <li>
                                                            <p> <span class="gray_comment">
                                                                        <?php
                                                                        echo $product['WishlistProduct']['Product']['stock_detail'];
                                                                        ?>
                                                                    .
                                                                    Offered by
                    <?php
                    echo $product['WishlistProduct']['Product']['MasterProduct']['Seller']['bs_dis_name'];
                    ?>
                                                                </span> </p>
                                                        </li>
                                                        <li>
                                                            <p>
                    <?php
                    if (isset($product['WishlistProduct']['Product']['offers']) and ($product['WishlistProduct']['Product']['offers'])) {
                        echo "<ul class='def_ul'>";
                        foreach ($product['WishlistProduct']['Product']['offers'] as $offer) {
                            //pr($offer);
                            // exit;
                            echo "<li>";
                            $slug = str_replace(" ", "_", strtolower("" . $offer['name'] . ""));
                            echo $html->link($offer['count'], array(
                                'controller' => 'products',
                                'action' => 'offer_listing',
                                $product['WishlistProduct']['Product']['wisn'],
                                $slug
                                    ), array(
                                'class' => 'blue_link',
                                'escape' => false
                            ));
                            echo ' from <span class="red">$' . $offer[$offer['name']] . '</span>';
                            echo "</li>";
                        }
                        echo "</ul>";
                    }
                    ?>
                                                            </p>
                                                        </li>
                                                        <li>
                                                                <?php
                                                                echo $html->link("Add to cart", array(
                                                                    'controller' => 'products',
                                                                    'action' => 'cart',
                                                                    "add",
                                                                    $product['WishlistProduct']['Product']['slug']
                                                                        ), array(
                                                                    'class' => "small_add2cart"
                                                                ));
                                                                ?>
                                                            &nbsp;&nbsp;&nbsp;
                                                            <?php
                                                            echo $html->link('Delete', array(
                                                                'controller' => 'products',
                                                                'action' => 'delete',
                                                                'WishlistProduct',
                                                                base64_encode($product['WishlistProduct']['id']),
                                                                'MyWishlist'
                                                                    ), array(
                                                                'escape' => false,
                                                                'class' => 'brown_link'
                                                                    ), 'Are you sure?');
                                                            ?>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                            <div class="width_19 f_right">
                                                <p>Added <b>
                                                            <?php
                                                            echo date("d M Y", strtotime($product['WishlistProduct']['Product']['created']));
                                                            ?>
                                                    </b> </p>
                                            </div>
                                        </li>
                    <?php
                    $x++;
                }
                ?>
                                </ul>
                                                    <?php
                                                }
                                                ?>
                        </div>
                    </div>
                                <?php
                                $x_w++;
                            }
                        }
                        ?>
        </div>
    </div>
                    <?php
                }
                ?>
